var path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin')

//定义路径
var root_path = path.resolve(__dirname)
var app_path = path.resolve(root_path, 'app')
var build_path = path.resolve(root_path, 'build')
var temp_path = path.resolve(root_path, 'template')

module.exports = {
	entry: {
		app: app_path
	},
	output: {
		path: build_path,
		filename: 'bundle.js'
	},
	plugins: [
		new HtmlWebpackPlugin({
			title: 'Hello World App',
			template: path.resolve(temp_path, 'index.html'),
			filename: 'index.html',
			chunks: ['app'],
			inject: 'body'
		})
	],
	devServer: {
		historyApiFallback: true,
		hot: true,
		inline: true
	},
	module: {
		loaders: [
			{
				test: /\.css$/,
				loaders: ['style-loader', 'css-loader'],
				include: app_path
			},{
				test: /\.scss$/,
				loaders: ['style-loader', 'css-loader', 'sass-loader'],
				include: app_path
			},{
				test: /\.(png|jpg)$/,
				loader: 'url-loader?limit=40000'
			},{
				test: /\.jsx?$/,
				loader:'babel-loader',
				include: app_path,
				query: {
					presets: ['es2015']
				}
			}
		]
	},
	resolve: {
		alias: {
			'vue$': 'vue/build/vue.common.js'
		}
	}
}
